import { emit } from 'process';
<template>
  <div class="pagination">
    <el-pagination
      v-model:current-page="pagination.pageNum"
      :page-size="pagination.pageSize"
      :page-sizes="pagination.pageSizes"
      :layout="pagination.layout"
      :total="pagination.totalCount"
      prev-text="上一页"
      next-text="下一页"
      @update:page-size="pageSizeChange"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup lang="ts">
const props = defineProps({
  // 分页对象
  pagination: Object,
});
const emit = defineEmits(["sizeChange", "currentChange", "pageSizeChange"]);
// 每页显示条数变化 -page-size 改变时触发
const handleSizeChange = (val: any) => {
  emit("sizeChange", val);
};
//current-page变化时-页码变化时
const handleCurrentChange = (val: any) => {
  emit("currentChange", val);
};
// 每页条数变更时的函数
const pageSizeChange = (val: any) => {
  console.log(val);
  emit("pageSizeChange", val);
};
</script>

<style scoped lang="scss">
.pagination {
  display: flex;
  justify-content: center;
}
</style>
